package com.bilibili.xzz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bilibili.xzz.entity.Video;
import com.bilibili.xzz.mapper.VideoMapper;
import com.bilibili.xzz.service.VideoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {

    @Resource
    VideoMapper videoMapper;


    @Override
    public Video getVideoById(Long id) {
        return  videoMapper.selectById(id);
    }

    @Override
    public List<Video> getAllVideo() {
        return videoMapper.selectList(null);
    }

    @Override
    public int deleteVideo(String title) {

            return videoMapper.delete((new QueryWrapper<Video>().eq("title",title)));

    }

    @Override
    public int insertVideo(Video video) {
        return videoMapper.insert(video);
    }

}
